<!--
 * @Descripttion: 
 * @Author: zhanyi
 * @Date: 2021-10-27 11:06:41
 * @FilePath: \wczd-mobile\src\pages\danger\danger-check.vue
-->
<template>
  <zPaging class="danger-check" :default-page-size="10" :fixed='false' height='100%' ref="paging" @query="queryList" v-model="managerModifyData" :delay='200' :refresher-end-bounce-enabled="false">
    <div class="cont-item" v-for="(item,index) in managerModifyData" :key="index" @click="_goInfo(item)">
      <div class="title">
        <div class="left">{{item.dangerName}}</div>
        <div class="right danger-state" :class="_isTextColor(item)">{{_recState(item)}}</div>
      </div>
      <div class="center">
        <div class="center-item">
          <div class="left">整改人</div>
          <div class="right">{{item.recUsername}}</div>
        </div>
        <div class="center-item">
          <div class="left">整改到期时间</div>
          <div class="right">{{item.requireEndTm}}</div>
        </div>
        <div class="center-item">
          <div class="left">部门</div>
          <div class="right">{{item.recDeptname}}</div>
        </div>
      </div>
      <div class="footer">
        <div class="left">
          {{_dangerName(item)}}
        </div>
        <div class="right">
          <image src="@/static/wczd/more.png" alt="">
        </div>
      </div>
    </div>
  </zPaging>
</template>

<script>
import { selectCheckDangerToMine } from "@/api/danger";
import zPaging from '@/uni_modules/z-paging/components/z-paging/z-paging.vue'
import ZPagingMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin'
import customNomore from '@/pages/component/custom-nomore/custom-nomore.vue'

export default {
  name: 'danger-check',
  components: { zPaging, customNomore },
  mixins: [ZPagingMixin],
  data () {
    return {
      managerModifyData: [],
      recState: []
    }
  },
  created () {
    this.getDicts('rec_state').then((response) => {
      this.recState = response.data
    })
  },
  computed: {
    // 操作名称
    _dangerName: function () {
      return function (item) {
        return item.recState === '2' ? '点击隐患验收' : '点击查看详情'
      }
    },
    // 计算整改状态
    _recState () {
      return function (item) {
        for (let index = 0; index < this.recState.length; index++) {
          const element = this.recState[index];
          if (element.dictValue === item.recState) {
            return element.dictLabel
          }
        }
      }
    },
    // 计算颜色样式
    _isTextColor: function () {
      return function (item) {
        return item.recState === '1' ? '_YELLOW' : item.recState === '2' ? '_YELLOW' : item.recState === '3' ? '_GREEN' : '_RED'
      }
    },
  },
  methods: {
    // z-paging 刷新页面
    reload () {
      this.$refs.paging.reload(false)
    },
    // z-paging 查询方法
    queryList (pageNo, pageSize) {
      console.log(pageNo, pageSize);
      uni.showLoading({
        title: '加载中'
      });
      selectCheckDangerToMine({}, { pageNum: pageNo, pageSize: pageSize }).then(res => {
        this.$refs.paging.complete(res.rows);
        uni.hideLoading();
      })
    },
    // 详情
    _goInfo (item) {
      uni.navigateTo({
        url: `/pages/danger/danger-check-edit?id=${item.id}&dangerId=${item.dangerId}`,
      })
    }
  },
}
</script>

<style scoped lang="scss">
.danger-check {
  overflow: auto;
  .cont-item {
    margin: 20upx auto 20upx;
    width: 680upx;
    background-color: #fff;
    border-radius: 10upx;
    padding: 15upx 30upx 0 30upx;
    .title {
      display: flex;
      justify-content: space-between;
      .left {
        padding-left: 20upx;
        font-size: 30upx;
        font-weight: bold;
        &::before {
          content: "";
          position: relative;
          left: -20upx;
          height: 30upx;
          width: 3upx;
          border-left: 3px solid #009fdf;
        }
      }
      .right {
        font-size: 30upx;
      }
    }
    .center {
      padding: 10upx 0;
      .center-item {
        display: flex;
        line-height: 60upx;
        color: #8d9093;
        .left {
          width: 30%;
          text-align: left;
        }
        .right {
          width: 70%;
          text-align: right;
        }
      }
    }
    .footer {
      height: 80upx;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-top: 1px solid #e8e9e9;
      .left {
        font-weight: bold;
        color: #009fdf;
      }
      .right {
        display: flex;
        align-items: center;
        image {
          width: 56upx;
          height: 56upx;
        }
      }
    }
  }
}
</style>
